import { defineStore } from "pinia";
import { TableOption, PaginationOption } from "@/typings/table";

export const useTableStore = defineStore("table", () => {
  /**每页数据量 */
  const pageSize = 10;
  /**当前页下标 */
  const pageIndex = 1;
  /**表格是否需要重新渲染 */
  const tableRender = false;
  /**表格是否需要加载 */
  const tableloading = false;
  /**表单重置标志 */
  const tableReset = false;
  const tableOption: TableOption = {
    data: [],
    stripe: true,
    border: false,
    columnName: [],
  };

  const paginationOption: PaginationOption = {
    layout: "->,prev, pager, next, jumper,sizes,total",
    total: 0,
    background: true,
    pageSize: 0,
    pagesizes: [10, 20, 30, 50, 100],
    small: false,
  };

  function changeTableOption() {}

  return {
    pageSize,
    pageIndex,
    tableRender,
    tableloading,
    tableReset,
    tableOption,
    paginationOption,
    changeTableOption,
  };
});
